
"""
__version__ = "$Revision: 1.11 $"
__date__ = "$Date: 2004/08/12 19:18:52 $"
"""

from PythonCard import model, resource
import os

class ConfigureDialog(model.CustomDialog):
    def __init__(self, parent):
        # load the resource
        path = os.path.join(parent.application.applicationDirectory, \
                            model.internationalResourceName('dlg_config'))
        aDialogRsrc = resource.ResourceFile(path).getResource()
        model.CustomDialog.__init__(self, parent, aDialogRsrc)
        
        # if some special setup is necessary, do it here
        #~ self.components.field1.text = ""
        self.components.fromName.text = parent.fromName
        self.components.fromAttribution.text = parent.fromAttribution
        self.components.fromAddress.text = parent.fromAddress
        self.components.replyAddress.text = parent.replyAddress
        self.components.SMTPserver.text = parent.SMTPserver
        self.components.POPserver.text = parent.POPserver
        self.components.POPuser.text = parent.POPuser
        self.components.POPpwd.text = parent.POPpwd
        self.components.CheckAtStart.checked = parent.CheckAtStart
        self.components.AutoCheck.checked = parent.AutoCheck
        self.components.AutoCheckInterval.value = parent.AutoCheckInterval
        self.components.PreviewLines.value = parent.PreviewLines
        self.components.POPserver.setFocus()

    # these shouldn't be necessary
    # but I haven't taken the time to figure out what is messed up in
    # the event dispatch that keeps event.skip from being called automatically
    # there might be a problem specific to wxDialog
    def on_btnOK_mouseClick(self, event):
        event.skip()

    def on_btnCancel_mouseClick(self, event):
        event.skip()


def configureDialog(parent):
    dlg = ConfigureDialog(parent)
    result = dlg.showModal()
    result.fromName = dlg.components.fromName.text
    result.fromAttribution = dlg.components.fromAttribution.text
    result.fromAddress = dlg.components.fromAddress.text
    result.replyAddress = dlg.components.replyAddress.text
    result.SMTPserver = dlg.components.SMTPserver.text
    result.POPserver = dlg.components.POPserver.text
    result.POPuser = dlg.components.POPuser.text
    result.POPpwd = dlg.components.POPpwd.text
    result.CheckAtStart = dlg.components.CheckAtStart.checked
    result.AutoCheck = dlg.components.AutoCheck.checked
    result.AutoCheckInterval = dlg.components.AutoCheckInterval.value
    result.PreviewLines = dlg.components.PreviewLines.value
    dlg.destroy()
    return result
